package day01.日期类.Acm;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Date;
import java.util.Scanner;

/**
 * @author feng
 * @Date 2022/1/3 20:20
 * 编写程序，从出生到现在过去了多少天?
 */
public class Test4 {
    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入生日:");
        String s = sc.nextLine();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
        Date birth = dateFormat.parse(s);
        //将日期转换成时间
        long time = birth.getTime();
        Date date = new Date();
        long time1 = date.getTime();
        long totalTime = time1 - time;
        long day = totalTime / 1000 / 60 / 24/60;
        System.out.println("出生到现在的天数" + day);
    }
}
